<template>
  <div>
    <div class="section" v-for="item in list" :key="item.channel_info.id">
      <p class="title"><span @click="gotoTearch(item.channel_info.id)">{{ item.channel_info.name }}</span><span @click="gotoTearch(item.channel_info.id)" class="one">更多</span></p>
      <div class="card-list">
        <div v-for="s in item.list" :key="s.teacher_id">
          <div class="card" @click="gotoDetail(s,item)">
            <div class="avatar-box"><img :src="s.teacher_avatar || s.cover_img" alt=""></div>
            <div class="info">
              <p>{{ s.teacher_name || s.title}}</p>
              <p>{{ s.introduction || s.price}}</p>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {appIndex} from "@/utils/api";
export default {
  name: "mySection",
  data(){
    return {
      list:[]
    }
  },
  created() {
    appIndex().then(res=>{
      // console.log(res)
      this.list = res.data
    })
  },
  methods:{
    gotoTearch(item){
      // console.log(item);
      this.$emit('gotoTearch',item)
    },
     gotoDetail(s,item){
      // console.log(s);
      console.log(item.channel_info.type);
      this.$emit("gotoDetail",s,item.channel_info.type)
      
    }
  }
}
</script>

<style scoped lang="scss">
.section {
  width: 100%;
  background-color: #f7f8fa;
  .title {
    display: flex;
    justify-content: space-between;
    padding: 0 27px;
    font-size: 16px;
    color: #595959;
    font-weight: 500;
    &::before {
      margin-top: 3.8px;
      position: absolute;
      content: "";
      left: 0.4rem;
      width: 0.08rem;
      height: 0.42667rem;
      background: #e60012;
    }
    &::after{
      margin-top: 3.4px;
      position: absolute;
      content: "";
      right: 0.4rem;
      width: 0.24rem;
      height: 0.37333rem;
      background: url('') no-repeat;
      background-size: 100% 100%;
    }
    .one {
      font-size: 14px;
    }
  }
  .card-list {
    padding: 15px;
    .card {
      padding: 15px;
      margin-bottom: 15px;
      background-color: white;
      border-radius: 12px;
      display: flex;
      align-items: center;
      .avatar-box {
        margin-right: 12px;
        height: 51px;
        display: flex;
        align-items: center;
        img {
          width: 40px;
          height: 40px;
          border-radius: 50%;
        }
      }
      .info {
        display: flex;
        flex-direction: column;
        p {
          &:first-child {
            margin-bottom: 5px;
            font-size: 15px;
          }
          &:last-child {
            color: #8c8c8c;
          }
        }
      }
    }
  }
}
</style>